package com.dearbinge.web.user.controller;

import io.swagger.annotations.ApiOperation;
import net.sf.json.JSONObject;

import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;

import com.dearbinge.utils.ResultMsg;
import com.dearbinge.utils.httpClient.ApiRequest;
import com.dearbinge.utils.httpClient.ApiResponse;

@SuppressWarnings("all")
@RestController
@RequestMapping("/php")
@EnableAutoConfiguration
public class PhpInterfaces extends WebMvcConfigurerAdapter {




	@ApiOperation(value = "顶部信息", notes = "顶部信息")
	@RequestMapping(value = "/indexIco", method = RequestMethod.GET)
	public ResultMsg<JSONObject> indexIco() {
		try {
			ApiResponse api = new ApiRequest("http://uv.aichengjt.com/app/index.php?i=1&c=entry&m=ewei_shopv2&do=mobile&r=account.index_10_ico",ApiRequest.Verb.GET).charset("UTF-8").send();
			String result = new String(api.getContent(), "UTF-8");
			JSONObject json = JSONObject.fromObject(result);
			return ResultMsg.ok(json);
		} catch (Exception e) {
			e.printStackTrace();
		}
		return ResultMsg.error(500, "error");
	}

	@ApiOperation(value = "秒杀数据", notes = "秒杀数据")
	@RequestMapping(value = "/indexBuyNow", method = RequestMethod.GET)
	public ResultMsg<JSONObject> indexBuyNow() {
		try {
			ApiResponse api = new ApiRequest("http://uv.aichengjt.com/app/index.php?i=1&c=entry&m=ewei_shopv2&do=mobile&r=account.index_buy_now",ApiRequest.Verb.GET).charset("UTF-8").send();
			String result = new String(api.getContent(), "UTF-8");
			JSONObject json = JSONObject.fromObject(result);
			return ResultMsg.ok(json);
		} catch (Exception e) {
			e.printStackTrace();
		}
		return ResultMsg.error(500, "error");

	}

	@ApiOperation(value = "商品分类", notes = "商品分类")
	@RequestMapping(value = "/indexCatGoods", method = RequestMethod.GET)
	public ResultMsg<JSONObject> indexCatGoods() {
		try {
			ApiResponse api = new ApiRequest("http://uv.aichengjt.com/app/index.php?i=1&c=entry&m=ewei_shopv2&do=mobile&r=account.index_cat_goods",ApiRequest.Verb.GET).charset("UTF-8").send();
			String result = new String(api.getContent(), "UTF-8");
			JSONObject json = JSONObject.fromObject(result);
			return ResultMsg.ok(json);
		} catch (Exception e) {
			e.printStackTrace();
		}
		return ResultMsg.error(500, "error");

	}

	@ApiOperation(value = "推荐商品", notes = "推荐商品")
	@RequestMapping(value = "/indexTjGoods", method = RequestMethod.GET)
	public ResultMsg<JSONObject> indexTjGoods() {
		try {
			ApiResponse api = new ApiRequest("http://uv.aichengjt.com/app/index.php?i=1&c=entry&m=ewei_shopv2&do=mobile&r=account.index_tj_goods",ApiRequest.Verb.GET).charset("UTF-8").send();
			String result = new String(api.getContent(), "UTF-8");
			JSONObject json = JSONObject.fromObject(result);
			return ResultMsg.ok(json);
		} catch (Exception e) {
			e.printStackTrace();
		}
		return ResultMsg.error(500, "error");
	}

	@ApiOperation(value = "热销品牌", notes = "热销品牌")
	@RequestMapping(value = "/indexHotBrand", method = RequestMethod.GET)
	public ResultMsg<JSONObject> indexHotBrand() {
		try {
			ApiResponse api = new ApiRequest("http://uv.aichengjt.com/app/index.php?i=1&c=entry&m=ewei_shopv2&do=mobile&r=account.index_hot_brand",ApiRequest.Verb.GET)
			.charset("UTF-8")
			.send();
			String result = new String(api.getContent(), "UTF-8");
			JSONObject json = JSONObject.fromObject(result);
			return ResultMsg.ok(json);
		} catch (Exception e) {
			e.printStackTrace();
		}
		return ResultMsg.error(500, "error");

	}



}
